﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Chefbook.DataObjects;
using NUnit.Framework;
using Rhino.Mocks;

using Chefbook.UserActions;
using Chefbook.ViewModels;

namespace UnitTests.UserActionsTests
{
    [TestFixture]
    public class RenameCategoryActionFixture
    {
        private MockRepository mocks;
        private IUserAction action;
        private CategoryViewModel category;
        private RecipeViewModel recipe;
        private string oldName, newName;

        [SetUp]
        public void Init()
        {
            mocks = new MockRepository();
            
            oldName = "old";
            newName = "new";
            
            category = new CategoryViewModel(new Category(null)) { Name = oldName};
            recipe = new RecipeViewModel(new Recipe(category.CategoryModel));


            Assert.AreEqual("old", category.Name);

            action = new RenameCategoryAction(category,newName) ;
        }

        [Test]
        public void DoActionTest()
        {
            action.DoAction();
            Assert.AreEqual(newName, category.Name);
        }

        [Test]
        public void UndoActionTest()
        {
            action.DoAction();
            action.UndoAction();
            Assert.AreEqual(oldName, category.Name);
        }

        [Test]
        public void UndoActionWithoutDoingTest()
        {
            UserActionTestsHelper.UndoActionWithoutDoingTest(action);
        }

        [Test]
        public void UndoActionTwiceAfterDoingTest()
        {
            UserActionTestsHelper.UndoActionTwiceAfterDoingTest(action);
        }

        [Test]
        public void DoActionTwiceTest()
        {
            UserActionTestsHelper.DoActionTwiceTest(action);
        }

        [Test]
        public void ActionNameTest()
        {
            Assert.AreEqual(string.Format("Rename Category from '{0}' to '{1}'", oldName, newName), action.ToString());
        }


    }
}
